import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import { addcount, jiancount } from '../../store-rtk-module/slices/shopcar'
import { addAge, setschoollistAsync } from '../../store-rtk-module/slices/user'
const Father = () => {
    const Store = useSelector(state => state);
    console.log('Store', Store);
    const dispatch = useDispatch()


    useEffect(() => {
        dispatch(setschoollistAsync())
    })
    return (
        <div>
            {/* shop数据 */}
            <p onClick={() => {
                dispatch(addcount());
            }}>count: {Store.shopcar.count}</p>
            {/* 用户数据 */}
            <p onClick={() => {
                dispatch(addAge(5))
            }}>user:{Store.user.userinfo.name}--{Store.user.userinfo.age}</p>
            <ul>
                {
                    Store.user.schoollist.map(item => <li key={item.id}>{item.school_name}</li>)
                }
            </ul>
        </div>
    );
}

export default Father;
